<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
	<title>免费wifi列表</title>

	<!-- Bootstrap -->
	<link href="http://cdn.bootcss.com/weui/0.4.2/style/weui.min.css" rel="stylesheet">
	<link href="wifi-weui-list-style.css" rel="stylesheet">

</head>
<body ontouchstart>
	<div class="container" id="container">
		<div class="hd">
			<h1 class="page_title">免费wifi列表</h1>
			<p class="page_desc"><a href="http://weixin-img.zhangxingdong.cn/service.html">《服务声明》</a></p>
		</div>

<?php
	$url = "http://apis.juhe.cn/wifi/local?key=3e779cd76d1fb42b17f768b731c09f93&lat=".$_GET['lat']."&lon=".$_GET['lon']."&gtype=2";
	$resultJson = getCurl($url);
	$result = json_decode($resultJson, true);

	function getCurl($url){//get https的内容
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,$url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);//不输出内容
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
		$result =  curl_exec($ch);
		curl_close ($ch);
		return $result;
	}
	if($result){
		if($result['error_code']=='0'){
			$num = count($result['result']['data']);
			for ($i=0; $i<$num; $i++) {
				$name = eval("result['result']['data'][$i]['name']");
				$intro = eval("result['result']['data'][$i]['intro']");
				$address = eval("result['result']['data'][$i]['address']");
				$distance = eval("result['result']['data'][$i]['distance']");
				/* $i = 0;
				$name = $result['result']['data'][0]['name'];
				$intro = $result['result']['data'][0]['intro'];
				$address = $result['result']['data'][0]['address'];
				$distance = $result['result']['data'][0]['distance']; */
				echo "<div class='weui_cells_title'>".$i."</div>";
				echo "<div class='weui_cells'>";
				echo "<div class='weui_cell'><div class='weui_cell_bd weui_cell_primary'><p>名称：</p></div><div class='weui_cell_ft'>".$$name."</div></div>";
				echo "<div class='weui_cell'><div class='weui_cell_bd weui_cell_primary'><p>介绍：</p></div><div class='weui_cell_ft'>".$$intro."</div></div>";
				echo "<div class='weui_cell'><div class='weui_cell_bd weui_cell_primary'><p>地址：</p></div><div class='weui_cell_ft'>".$$address."</div></div>";
				echo "<div class='weui_cell'><div class='weui_cell_bd weui_cell_primary'><p>距离：</p></div><div class='weui_cell_ft'>".$$distance."</div></div>";
				echo "</div>";
			}
		}else{
			$contentStr = $result['error_code'].":".$result['reason'];
?>
		<div class="hd">
			<div class="bd spacing">
				<i class="weui_icon_msg weui_icon_warn"></i>
			</div>
			<h1 class="warn_title"><?php echo $contentStr; ?></h1>
		</div>
<?php
		}
	}else{
?>
		<div class="hd">
			<div class="bd spacing">
				<i class="weui_icon_msg weui_icon_warn"></i>
			</div>
			<h1 class="warn_title">请求失败</h1>
		</div>
<?php
	}
?>

	</div>
	<!-- <script src="https://weui.io/zepto.min.js"></script>
	<script src="https://weui.io/router.min.js"></script>
	<script src="wifi-weui-list.js"></script> -->
</body>
</html>